package com.xinruke.hostels.dailymanage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.dailymanage.interfaces.dto.*;
import com.xinruke.hostels.dailymanage.service.CommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author ChenXiangpeng
 * @ClassName CommentInnerAPIController
 * @date：2019/7/27
 * @version: V1.0.0
 * @description：
 */
@RestController
@RequestMapping("/commentInnerApi")
@Api(tags = "评论管理内部接口")
public class CommentInnerAPIController extends BaseController {
    Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private CommentService commentService;

    @PostMapping("/list")
    @ApiOperation("中央管理全部评论列表")
    public ResultVO<RowsDataVO<CommentInfoQueryResultDTO>> allComment(@RequestBody @Valid CommentAllInfoQueryDTO commentAllInfoQueryDTO){
        logger.info("日常管理服务Controller---根据条件获取结果的参数:{}",commentAllInfoQueryDTO);

        return commentService.allComment(commentAllInfoQueryDTO);
    }

    /**
     * 得到订单的评价信息
     *
     */
    @PostMapping("/detail")
    @ApiOperation("中央管理评论详情")
    public ResultVO<CommentDetailQueryResultDTO> centralDetail(@Valid @RequestBody CommentDetailQueryDTO params) {
        return commentService.detailById(params);
    }

    /**
     * 删除
     *todo 什么时候可以删除
     */
    @PostMapping("/del")
    @ApiOperation("中央管理删除评论")
    public ResultVO<String> del(@Valid @RequestBody CommentDelQueryDTO params) {
        return commentService.del(params);
    }

    /**
     * 审核评论
     *
     */
    @PostMapping("/audit")
    @ApiOperation("中央管理审核评论")
    public ResultVO<String> audit(@Valid @RequestBody CommentAuditQueryDTO params) {
        return commentService.audit(params);
    }
}
